package com.zhiyou100.blog.service;

import com.sun.xml.internal.org.jvnet.fastinfoset.FastInfosetException;
import com.zhiyou100.blog.dao.UserDao;
import com.zhiyou100.blog.dao.impl.EndorseDaoImpl;
import com.zhiyou100.blog.dao.impl.UserDaoImpl;
import com.zhiyou100.blog.entity.User;
import org.junit.Test;

import java.util.List;

/**
 * @author shkstart
 * @create 2021-10-23 9:58
 */
public class UserService {
    private UserDao dao = new UserDaoImpl();

    /**
     * 获取明星会员
     *
     * @return
     */
    public List<User> getStartUserList() {
        List<User> list = dao.getListOrderByMaxScore();
        return list;
    }


    public User getUserLvAndListFen(Integer id) {
        User user = null;
        List<User> list = dao.getUserLvById(id);
        for (User e : list) {
            if (e.getLv() != null) {
                user = e;
            }
        }
        user.setFen(dao.getListFenById(user.getUid()));
        return user;
    }

    /**
     * 查询一个 用户 包括 赞虚
     * @param uid
     * @return
     */
    public User getUserAndZanXuByUid(int uid) {
        EndorseDaoImpl endorseDao = new EndorseDaoImpl();
        User user = dao.getOneById(uid);
//        user.setZan(endorseDao.getEndorseZanXuCountByUid(uid, true));
//        user.setXu(endorseDao.getEndorseZanXuCountByUid(uid, false));
        return user;
    }


    @Test
    public void test1() {
//        System.out.println(getUserLvAndListFen(4));
        System.out.println(getUserAndZanXuByUid(1));
    }
}
